- page_title "通知"

%div
  - if @user.errors.any?
    %div.alert.alert-danger
      %ul
        - @user.errors.full_messages.each do |msg|
          %li= msg

  = hidden_field_tag :notification_type, 'global'
  .row
    .col-lg-3.profile-settings-sidebar
      %h4
        = page_title
      %p
        你也可以单独指定每个群组或项目的通知等级。
      %p
        所有项目和群组默认使用全局通知设置。
    .col-lg-9
      %h5
        全局通知设置

      = form_for @user, url: profile_notifications_path, method: :put, html: { class: 'update-notifications prepend-top-default' } do |f|
        .form-group
          = f.label :notification_email, '通知邮箱', class: "label-light"
          = f.select :notification_email, @user.all_emails, { include_blank: false }, class: "select2"
        .form-group
          = f.label :notification_level, '通知等级', class: 'label-light'
          .radio
            = f.label :notification_level, value: :disabled do
              = f.radio_button :notification_level, :disabled
              .level-title
                关闭
              %p 将不会通过邮件收到任何通知

          .radio
            = f.label :notification_level, value: :mention do
              = f.radio_button :notification_level, :mention
              .level-title
                被提及
              %p 只收到评论中 @自己 的通知

          .radio
            = f.label :notification_level, value: :participating do
              = f.radio_button :notification_level, :participating
              .level-title
                参与
              %p 只收到有关的通知 (比如：来自自己的提交或指派给自己的问题)

          .radio
            = f.label :notification_level, value: :watch do
              = f.radio_button :notification_level, :watch
              .level-title
                关注
              %p 将收到参与项目的所有通知

        .prepend-top-default
          = f.submit '更新设置', class: "btn btn-create"
      %hr
      %h5
        群组 (#{@group_notifications.count})
      %div
        %ul.bordered-list
          - @group_notifications.each do |setting|
            = render 'group_settings', setting: setting, group: setting.source
      %h5
        项目 (#{@project_notifications.count})
      %p.account-well
        给所属群组的每个项目指定通知等级，需要访问项目页面去设置通知等级。
      .append-bottom-default
        %ul.bordered-list
          - @project_notifications.each do |setting|
            = render 'project_settings', setting: setting, project: setting.source
